package dome1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2024-05-23
 * Time: 15:56
 */
import java.util.Arrays;
import java.util.Scanner;
//import java.util.Date;

class Date{
    public int year;
    public int month;
    public int day;

    public Date(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }

    @Override
    public String toString() {
        return year + "-" + month + "-" + day;
    }
}

class Student implements Comparable<Student> {
    private String name;
    private Date birthday;
    private String studentId;
    private String school;

    // 构造函数
    public Student(String name, int year, int month, int day, String studentId, String school) {
        this.name = name;
        this.birthday = new Date(year, month, day);
        this.studentId = studentId;
        this.school = school;
    }

    // 重写toString方法
    @Override
    public String toString() {
        return "Student[name=" + name + ", birthday=" + birthday + ", studentId=" + studentId + ", school=" + school + "]";
    }

    // 重写equals方法
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        Student student = (Student) obj;
        return studentId.equals(student.studentId);
    }

    // 重写hashCode方法
    @Override
    public int hashCode() {
        return studentId.hashCode();
    }

    // 实现Comparable接口的compareTo方法，按照学号大小进行比较
    @Override
    public int compareTo(Student student) {
        return studentId.compareTo(student.studentId);
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        Student[] studentArray = new Student[num];
        for (int i = 0; i < num; i++) {
            String name = in.next();
            int year = in.nextInt();
            int month = in.nextInt();
            int day = in.nextInt();
            String studentId = in.next();
            String school = in.next();
            studentArray[i] = new Student(name, year, month, day, studentId, school);
        }

        Arrays.sort(studentArray);
        for (Student s : studentArray)
            System.out.println(s);
    }
}